package com.zkingsoft.zkingbase.base;

import android.app.Application;
import android.os.Handler;
import android.util.Log;

import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import com.zhy.autolayout.config.AutoLayoutConifg;
import com.zkingsoft.zkingbase.constant.Constant;
import com.zkingsoft.zkingbase.manager.LogManager;

import cn.jpush.android.api.JPushInterface;
import cn.smssdk.SMSSDK;

/**
 * Created by ytf on 2017/3/3 003.
 * Description:
 */

public class ZkApplication extends Application
{

    private static Handler handler;
    private static ZkApplication context;
    private IWXAPI wxApi;

    @Override
    public void onCreate()
    {
        super.onCreate();
        context = this;
        handler = new Handler();

        //开启log
        LogManager.getInstance().setDebug(true);

        wxApi = WXAPIFactory.createWXAPI(this,Constant.WX_ID);

        //初始化Autolayout
        AutoLayoutConifg.getInstance().useDeviceSize();

        initUM();

        //初始化全局异常处理
//        CrashHandler.getInstance().init(this);

        //极光推送
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
    }

    public IWXAPI getWxApi()
    {
        return wxApi;
    }

    private void initUM() {
        // 开启debug模式，方便定位错误
        Config.DEBUG = true;
        UMShareAPI.get(this);
        // 友盟 各个平台的配置
        PlatformConfig.setWeixin("111", "111");
        PlatformConfig.setQQZone("111", "111");
        PlatformConfig.setSinaWeibo("111", "111", "111");
    }

    public static ZkApplication getAppContext()
    {
        return context;
    }

    public static Handler getHandler()
    {
        return handler;
    }

}
